<?php
// implementation of add function
function getMO($commandcode,$serviceid,$userid,$message,$requestid,$username,$password) {
	if($username == "south" && $password=="south.123!@#"){
		//$this->load->model('transms_model');
		//$this->transms_model->add_mo($userid,$serviceid,$commandcode,$message,$requestid);
		//$this->sendMT($userId);
		insertsms($commandcode,$serviceid,$userid,$message,$requestid);
		return $userid.' da dang ky thanh cong dich vu';
	}else {
		return "error";
	}
}
 
function insertsms($commandcode,$serviceid,$userid,$message,$requestid){
	connectdb();
	$createdate=date("d-m-Y h:i:s A");
	mysql_query("INSERT INTO tbmos (dest, phone, content,createdate,telco,cmdcode,requestId)
	VALUES ($serviceid,$userid,$message,$createdate,'',$commandcode,$requestid)");
	if (!mysql_query($sql,$con))
	  {
	  	die('Error: ' . mysql_error());
	  } 
	closedb();
}

function connectdb(){
	$con = mysql_connect("localhost","honeyhubby_ad8x","Xuanson270986!");
	if (!$con)
	  {
	  die('Could not connect: ' . mysql_error());
	  }
	
	mysql_select_db("honeyhubby_store8x", $con);
}

function closedb(){
	mysql_close($con);
}


?>
  